import uuid
from typing import TypeVar

from sqlalchemy import ForeignKey
from sqlalchemy.orm import Mapped, mapped_column, relationship

from recruit.adapter.database.models import Base

User = TypeVar('User')
ResumeInfo = TypeVar('ResumeInfo')
ResumePosition = TypeVar('ResumePosition')
ResumeSalary = TypeVar('ResumeSalary')
ResumeContact = TypeVar('ResumeContact')
ResumeWork = TypeVar('ResumeWork')
ResumeSkill = TypeVar('ResumeSkill')
ResumeAboutUs = TypeVar('ResumeAboutUs')
ResumeEducation = TypeVar('ResumeEducation')


class Resume(Base):
    """ Model Resume. """
    id: Mapped[uuid.UUID] = mapped_column(
        primary_key=True,
        default=uuid.uuid4
    )
    user_id: Mapped[uuid.UUID] = mapped_column(ForeignKey('user.id'))
    user: Mapped['User'] = relationship(
        back_populates='resume',
        lazy='selectin'
    )
    resume_info: Mapped['ResumeInfo'] = relationship(
        back_populates='resume',
        lazy='selectin',
        cascade='all, delete-orphan',
    )
    resume_position: Mapped['ResumePosition'] = relationship(
        back_populates='resume',
        lazy='selectin',
        cascade='all, delete-orphan',
    )
    resume_salary: Mapped['ResumeSalary'] = relationship(
        back_populates='resume',
        lazy='selectin',
        cascade='all, delete-orphan',
    )
    resume_contact: Mapped['ResumeContact'] = relationship(
        back_populates='resume',
        lazy='selectin',
        cascade='all, delete-orphan',
    )
    resume_work: Mapped[list['ResumeWork']] = relationship(
        back_populates='resume',
        lazy='selectin',
        cascade='all, delete-orphan',
    )
    resume_skill: Mapped['ResumeSkill'] = relationship(
        back_populates='resume',
        lazy='selectin',
        cascade='all, delete-orphan',
    )
    resume_about_us: Mapped['ResumeAboutUs'] = relationship(
        back_populates='resume',
        lazy='selectin',
        cascade='all, delete-orphan',
    )
    resume_education: Mapped[list['ResumeEducation']] = relationship(
        back_populates='resume',
        lazy='selectin',
        cascade='all, delete-orphan',
    )
